clear all; clc; close all;


N=1e6;
load Hd;
n=randn(1,N);
Fd=42.2e6;
Td=1/Fd;
T=N*Td;


N0=1;
stdn=N0/(2*Td);
n=stdn*randn(1,N);

y=filter(H.Numerator, 1,n);

figure(1);

f=0:1/T:(1/Td-1/T);
Sf=20*log10(abs(fft(y)));
Sf=Sf-max(Sf)+1;
plot(f/1e6,Sf);
xlim([0 Fd/2/1e6]);
xlabel('f,MHz')
grid on



Fd = 44.2e6/4; Td = 1/Fd;
tmax = 0.001; t = 0:Td:tmax;

N_PRN = 511; T_PRN = 0.001;
PRN = sign(randn(1, N_PRN));
ind_h = fix(mod(t/T_PRN, 1)*N_PRN) + 1;
h = PRN(ind_h);

A = 2;
f0 = 3e6;
phi = pi/4;

u = A * h .* cos(2*pi*f0*t + phi);

figure(2);
subplot(4,1,1)
plot(t,u)
subplot(4,1,2)
plot(t,h)
subplot(4,1,3)
plot(t,phase_h)
subplot(4,1,4)
plot(t,ind_h)